package myutil.mymap;

import java.util.Iterator;

/**
 *
 * @author Hlib_Babii
 * @since 1.0
 */
public interface MyMap<K,V> {
    /**
     * removes all of the mappings from this map.
     */
    void clear();
    
    /**
     * checks whether this map contains a mapping for the specified key.
     * @param key to be checked for
     * @return true if this map contains a mapping for the specified key,
     *              false otherwise.
     */
    boolean containsKey(K key);
    
    /**
     * checks if this map maps one or more keys to the specified value.
     * @param value to be checked for
     * @return true if this map maps one or more keys to the specified value,
     *              false otherwise.
     */
    boolean containsValue(V value);
    
    /**
     * returns the value to which the specified key is mapped, 
     * or {@code null} if this map contains no mapping for the key.
     * @param key key to get mapping for
     * @return the value to which the specified key is mapped, 
     * or {@code null} if this map contains no mapping for the key
     */
    Object get(K key);
    
    /**
     * checks if this map contains key-value mappings.
     * @return true if this map contains no key-value mappings,
     *          false otherwise
     */
    boolean isEmpty();
    
    /**
     * associates the specified value with the specified key in this map.
     * @param key key with which the specified value is to be associated
     * @param value value to be associated with the specified key
     * @return the previous value associated with {@code key}, or
     *         {@code null} if there was no mapping for {@code key}.
     *         (A {@code null} return can also indicate that the map
     *         previously associated {@code null} with {@code key},
     *         if the implementation supports {@code null} values.)
     */
    V put(K key, V value);
    
    /**
     * removes the mapping for the specified key from this map if present.
     * @param key to remove mapping for
     * @return the previous value associated with {@code key} or
     *         {@code null}> if there was no mapping for {@code key}
     */
    V remove(K key);
    
    /**
     * returns the number of key-value mappings in this map.
     * @return the number of key-value mappings in this map
     */
    int size();
    
    /**
     * returns an iterator over the elements (MyMap.Entry) in proper sequence
     * @return an iterator over the elements (MyMap.Entry) in proper sequence
     */
    Iterator entryIterator();
    
    interface Entry<K, V> {
        
        /**
         * сompares the specified object with this entry for equality.
         * @param o object to compare entry with
         * @return true if specified object and entry are equal,
         *              false otherwise
         */
        boolean equals(Object o);
        
        /**
         * returns the key corresponding to this entry.
         * @return the key corresponding to this entry.
         */    
        K getKey();
                
        /**
         * returns the value corresponding to this entry.
         * @return the value corresponding to this entry
         */       
        V getValue();
        
        /**
         * returns the hash code value for this map entry.
         * @return the hash code value for this map entry
         */
        int hashCode();
        
        /**
         * replaces the value corresponding to this entry with the specified value.
         * @param value value to replace with
         * @return old value corresponding to the entry
         */
        V setValue(V value);
    }
}
